import React, { Component } from 'react'

export default class App extends Component {
    a = 100
    // 状态与this指向
    render() {
        return (
            <div>
                <input />
                <button onClick={() => {
                    console.log("click1","如果处理逻辑较多，不推荐使用此种写法")
                }
                }>add1</button>

                <button onClick={this.handleClick2}>add2</button>
                <button onClick={this.handleClick3}>add3</button>
                <button onClick={ ()=> {
                    this.handleClick4() // 比较推荐
                }}>add4</button>  
                {/* 匿名箭头函数 */}

            </div>
        )
    }

    handleClick2(){
        console.log("click2")
    }

    handleClick3 = ()=>{
        console.log("click3")
    }

    handleClick4 = ()=>{
        console.log("click4")
    }
}
